import React, { createContext, useContext, ReactNode } from 'react';

interface AuthContextType {
    permissions: string[];
}

const AuthContext = createContext<AuthContextType | undefined>(undefined);

interface AuthProviderProps {
    children: ReactNode;
    permissions: string[];
}

export const AuthProvider: React.FC<AuthProviderProps> = ({ children, permissions }) => {
    return (
        <AuthContext.Provider value={{ permissions }}>
            {children}
        </AuthContext.Provider>
    );
};

export const useAuth = () => {
    const context = useContext(AuthContext);
    if (!context) {
        throw new Error('useAuth must be used within an AuthProvider');
    }
    return context;
};
